package com.tx.boot_demo.domain;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.util.Date;
import java.util.List;

/**
 * @ConfigurationProperties：绑定yml文件和javaBean对象
 *      prefix：绑定具体的配置
 * @Component: 只有注册成为组件，才能够使用@ConfigurationProperties提供的功能
 */
@Component
@ConfigurationProperties(prefix = "person")
@Validated
public class Person {

    //普通变量
    private String name;

    private boolean boss;

    private Date birthday;

//    @Email
    private String lastName;

    //对象或map
    private Food food;

    //集合或数组
    private List<String> lists;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isBoss() {
        return boss;
    }

    public void setBoss(boolean boss) {
        this.boss = boss;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Food getFood() {
        return food;
    }

    public void setFood(Food food) {
        this.food = food;
    }

    public List<String> getLists() {
        return lists;
    }

    public void setLists(List<String> lists) {
        this.lists = lists;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", boss=" + boss +
                ", birthday=" + birthday +
                ", lastName='" + lastName + '\'' +
                ", food=" + food +
                ", lists=" + lists +
                '}';
    }
}